Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support $ref #1208

Merged
merged 6 commits into from
Apr 7, 2022
Merged

feat: support $ref #1208

merged 6 commits into from
Apr 7, 2022

Conversation

hmil
Copy link
Contributor

@hmil hmil commented Apr 5, 2022

fixes #1207

Version

Published prerelease version: v1.1.0-next.0

Changelog

🎉 This release contains work from a new contributor! 🎉

Thank you, Hadrien Milano (@hmil), for all your work!

🚀 Enhancement

🐛 Bug Fix

🔩 Dependency Updates

Authors: 4

if (reachable.has(typeName)) {
// we've already processed this definition
const typeName = decodeURIComponent(definition.$ref.slice(DEFINITION_OFFSET));
if (reachable.has(typeName) || !isLocalRef(definition.$ref)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is too late. At this point we already generated the schema. It would be better to not even recurse into types when we have a ref.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll look into it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated AnnotatedNodeParser such that it short-circuits child type parsing if an explicit ref annotation was provided.
Instead, it sets the child type to AnyType. The AnyType is conveniently represented as an empty object which means we'll only get the $ref property in the output schema and no additional noise coming from the type itself.

@domoritz domoritz marked this pull request as draft April 5, 2022 16:45
@hmil hmil marked this pull request as ready for review April 6, 2022 10:27
nested: MyNestedObject

/**
* @ref http://json-schema.org/draft-07/schema#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does json schema support additional properties here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand. What do you mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a comment here and see that in the description of the json schema property?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 👍

@domoritz domoritz merged commit cdd587e into vega:next Apr 7, 2022
@domoritz
Copy link
Member

domoritz commented Apr 7, 2022

Thank you

@github-actions
Copy link

🚀 PR was released in v1.1.0 🚀

@github-actions github-actions bot added released This issue/pull request has been released. and removed prerelease labels Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support remote schemas via $ref
2 participants